#!/bin/bash
mkdir /usr/java/
cd src
tar zxvf jdk-8u121-linux-x64.tar.gz -C /usr/java/
ln -s /usr/java/jdk1.8.0_121/ /usr/java/jdk8
{
cat <<'jdk'
#set java environment
export JAVA_HOME=/usr/java/jdk8
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$CLASSPATH:$JAVA_HOME/lib:$JRE_HOME/lib
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
jdk
} >> /etc/profile
. /etc/profile
java -version

